<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .cube{
        width: 200px;
        height: 200px;
        position: relative;
        /* background-color: skyblue; */
        margin: 200px;

        /* perspective: 300px; */
        transform-style: preserve-3d;

         /* 添加动画属性 */
         animation: rotateCube 8s infinite linear;
         /* transform-origin: 0 0 0 ; */
    }

    .cube div{
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
    }

    .front{
        background-color: rgba(144,238,144,0.3);
    }

    .back{
        background-color: rgba(255,69,0,0.3);
        transform: translateZ(-200px);
    }

    .left{
        background-color: rgba(0,0,255,0.3);
        transform: rotateY(90deg);
        transform-origin: left center;
    }

    .right{
        background-color: rgba(255,0,255,0.3);
        transform: rotateY(-90deg);
        transform-origin: right center;
    }

    .top{
        background-color: rgba(0,255,0,0.3);
        transform: rotateX(-90deg);
        transform-origin: center top;
    }

    .bottom{ 
        background-color: rgba(255,255,0,0.3);
        transform: rotateX(90deg);
        transform-origin: center bottom;
    }

    @keyframes rotateCube {
        0% {
            transform: rotateX(0deg) rotateY(0deg);
        }
        25% {
            transform: rotateX(90deg) rotateY(90deg);
        }
        50% {
            transform: rotateX(180deg) rotateY(180deg);
        }
        75% {
            transform: rotateX(270deg) rotateY(270deg);
        }
        100% {
            transform: rotateX(360deg) rotateY(360deg);
        }
    }
</style>
<body>
    <div class="cube">
        <div class="front">前面</div>
        <div class="back">后面</div>
        <div class="left">左边</div>
        <div class="right">右边</div>
        <div class="top">上面</div>
        <div class="bottom">下面</div>
    </div>
</body>
</html>